#include "ProcessBar.h"

#define Length 51
#define BarStyle '#'

const char* icon = "/-\\|";

void ProcBar(double total, double current)
{
  char bar[Length];
  memset(bar, '\0', sizeof(bar));
  
  double scale = (current*(Length - 1)) / total;
  int count = (int)scale;
  int index = 0;

  while(count >= index)
  {
    bar[index++] = BarStyle;
  }
  const int icon_len = strlen(icon);
  printf("[%-50s][%3d%%][%c]\r", bar, count * 2, icon[count % icon_len]);
  fflush(stdout);
}
